package com.aauedu.springboot.controller;

import com.aauedu.bean.Car;
import com.aauedu.bean.Monster;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.Date;

/**
 * 返回json数据
 */
@Controller
public class ResponseController {

    @GetMapping("/get/monster")
    @ResponseBody
    public Monster getMonster() {
        Monster monster = new Monster();
        monster.setAge(100);
        monster.setBirth(new Date());
        monster.setMarried(false);
        monster.setName("牛魔王");
        Car car = new Car();
        car.setName("奔驰");
        car.setPrice(2222.2);
        monster.setCar(car);
        return monster;
    }
}
